package fauxman.FauxManStates;

import java.util.Collection;
import java.util.LinkedList;

import fauxman.DynamicElements.Bonus;
import fauxman.DynamicElements.FauxMan;
import fauxman.DynamicElements.Food;
import fauxman.DynamicElements.Ghost;
import fauxman.DynamicElements.Pellet;
import fauxman.Enums.GameElementName;
import fauxman.StaticElements.PlayableArea;
import fauxman.interfaces.DynamicElement;
import fauxman.model.WorldModel;
import fauxman.states.EatenGhostState;
import fauxman.states.GhostState;
import fauxman.states.VulnerableGhostState;

public class CorneringFauxManState extends FauxManState {
	private static CorneringFauxManState instance;
	
	private CorneringFauxManState(){
	}
	
	public static CorneringFauxManState getInstance(){
		if (instance==null)
			instance = new CorneringFauxManState();
		return instance;
	}

	@Override
	public void setNextDirection(int[] action, WorldModel model, FauxMan fauxMan) {
		//Cant change direction if in middle of cornering
	}
	
	@Override
	public int[] reactToCurrentContinuousPosition(WorldModel model, FauxMan fauxMan) {
		if(fauxMan.getConHitbox().x == fauxMan.getCorneringTrailEnd()[0] && fauxMan.getConHitbox().y == fauxMan.getCorneringTrailEnd()[1])
		{
			fauxMan.setCurrentDirection(fauxMan.getCorneringEndDirection());
			fauxMan.setNextDirection(fauxMan.getCorneringEndDirection());
			fauxMan.setState(NormalFauxManState.getInstance());
			return fauxMan.getCorneringEndDirection();
		}
		return null;
	}

	@Override
	public Collection<? extends PlayableArea> getPlayableArea(WorldModel model) {
		return model.getCorneringArea();
	}
	
}
